package com.bistu.sim.xwy.news.BusinessMode;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.bistu.sim.xwy.news.LoginActivity;
import com.bistu.sim.xwy.news.R;
import com.bistu.sim.xwy.news.MainActivity;
import com.bistu.sim.xwy.news.BusinessMode.BusMineActivity;
import com.bistu.sim.xwy.news.domain.BusUser;
import com.loopj.android.image.SmartImageView;

public class BusMineActivity extends AppCompatActivity implements View.OnClickListener {
    
    private LinearLayout index_bottom_bar_home;
    private LinearLayout index_bottom_bar_me;
/*    private LinearLayout index_bottom_bar_dynamic_state;
    private LinearLayout index_bottom_bar_integral;
    private LinearLayout index_bottom_bar_post;*/
    
    private TextView tv_name;
    private SmartImageView iv_avatar;
    private RelativeLayout iv_tuichu;
    private RelativeLayout re_businfo;
    private RelativeLayout luntan;
    private RelativeLayout guanli;
    
    private ImageView index_bottom_bar_home_image;
    private ImageView index_bottom_bar_me_image;
/*    private ImageView index_bottom_bar_dynamic_state_image;
    private ImageView index_bottom_bar_integral_image;
    private ImageView index_bottom_bar_post_image;*/
    
    private BusUser busUser;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bus_mine);
        initView();
    }

    private void initView() {
        index_bottom_bar_home = findViewById(R.id.index_bottom_bar_home);
        index_bottom_bar_me=findViewById(R.id.index_bottom_bar_me);
/*        index_bottom_bar_dynamic_state = findViewById(R.id.index_bottom_bar_dynamic_state);

        index_bottom_bar_integral=findViewById(R.id.index_bottom_bar_integral);*/
        
        re_businfo=findViewById(R.id.re_myinfo);
        tv_name=findViewById(R.id.tv_name);
        iv_avatar=findViewById(R.id.iv_avatar);
        iv_tuichu=findViewById(R.id.tuichu);
        luntan = findViewById(R.id.re_xiangce);
        guanli = findViewById(R.id.re_guanli);
        
/*        index_bottom_bar_post_image = (ImageView) findViewById(R.id.index_bottom_post_img);
        index_bottom_bar_post = findViewById(R.id.index_bottom_post);
        index_bottom_bar_dynamic_state_image = (ImageView) findViewById(R.id.index_bottom_bar_dynamic_state_image);
        index_bottom_bar_integral_image = (ImageView) findViewById(R.id.index_bottom_bar_integral_image);*/

        index_bottom_bar_me_image = (ImageView) findViewById(R.id.index_bottom_bar_me_image);
        index_bottom_bar_home_image = (ImageView) findViewById(R.id.index_bottom_bar_home_image);

        index_bottom_bar_me_image.setImageResource(R.mipmap.index_bottom_bar_me_select);

        index_bottom_bar_me.setOnClickListener(this);
        index_bottom_bar_home.setOnClickListener(this);

/*        index_bottom_bar_dynamic_state.setOnClickListener(this);
        index_bottom_bar_integral.setOnClickListener(this);
        index_bottom_bar_post.setOnClickListener(this);*/
        
        re_businfo.setOnClickListener(this);
        iv_tuichu.setOnClickListener(this);
        guanli.setOnClickListener(this);
        luntan.setOnClickListener(this);
    }

    public void onClick(View v) {
        switch (v.getId()){
            case  R.id.index_bottom_bar_home:
                Intent intent = new Intent(this, BusMainActivity.class);
                startActivity(intent);
                BusMineActivity.this.finish();
                overridePendingTransition(0,0);
                break;
/*case  R.id.index_bottom_bar_integral:
                Intent intent1 = new Intent(this, MessageActivity.class);
                startActivity(intent1);
                overridePendingTransition(0,0);
                BusMineActivity.this.finish();
                break;
            case  R.id.index_bottom_bar_dynamic_state:
                Intent intent2 = new Intent(this, FocusActivity.class);
                startActivity(intent2);
                overridePendingTransition(0,0);
                BusMineActivity.this.finish();
                break;
            case R.id.index_bottom_post:
                Intent intent4 = new Intent(this, PostActivity.class);
                startActivity(intent4);
                BusMineActivity.this.finish();
                overridePendingTransition(0,0);
                break;*/

            case  R.id.index_bottom_bar_me:
                Intent intent3 = new Intent(this,BusMineActivity.class);
                startActivity(intent3);
                overridePendingTransition(0,0);
                BusMineActivity.this.finish();
                break;
/*            case R.id.re_businfo:
                Intent intent5 = new Intent(this, BusInfoResetActivity.class);
                intent5.putExtra("bus_name",busUser.getBus_User_name());
                intent5.putExtra("bus_tel",busUser.getBus_User_tel());
                intent5.putExtra("bus_work",busUser.getBus_User_work());
                intent5.putExtra("bus_sex",busUser.getBus_User_sex());
                intent5.putExtra("bus_mail",busUser.getBus_User_mail());
                intent5.putExtra("bus_icon",busUser.getBus_User_icon());
                intent5.putExtra("bus_manage",busUser.getBus_user_manage());
                intent5.putExtra("bus_place",busUser.getBus_user_place());
                startActivity(intent5);
                break;*/
            case R.id.tuichu:
                SharedPreferences sp = getSharedPreferences("data", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sp.edit();
                editor.clear();
                editor.commit();
                Intent intent6 = new Intent(this, LoginActivity.class);
                startActivity(intent6);
                BusMineActivity.this.finish();
                break;
            case R.id.re_xiangce:
                Log.e("MineActivity","luntan");
                String luntan_url = getString(R.string.luntan_url);
                Intent intent7 = new Intent(Intent.ACTION_VIEW, Uri.parse(luntan_url));
                try {
                    startActivity(intent7);
                }catch (ActivityNotFoundException e){
                    Toast.makeText(getApplicationContext(), "未找到浏览器应用程序", Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.re_guanli:
                Log.e("MineActivity","guanli");
                String guanli_url = getString(R.string.guanli_url);
                Intent intent8 = new Intent(Intent.ACTION_VIEW, Uri.parse(guanli_url));
                try {
                    startActivity(intent8);
                }catch (ActivityNotFoundException e){
                    Toast.makeText(getApplicationContext(), "未找到浏览器应用程序", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}
